const axios = require("axios");
const puppeteer = require("puppeteer");

async function getIP() {
      const pattern = "json";
      const count = 1;
      const API_HOST = 'http://api.shenlongip.com';
      return axios.get(`${API_HOST}/ip?key=qn5xyxu9&pattern=${pattern}&count=${count}&sign=acb9a9262226758b12cbfab1dc659d8a`);
}

async function main() {
    // const ipRes = await getIP();
    // if (ipRes.data.code === 200) {
    //     // const ipObj = { ip: '125.79.50.209', port: 40009 };
    //     const ipObj = ipRes.data.data[0];
    //     // ipObj.ip  ipObj.port
    //     const options = {
    //         headless: false,
    //         args: [
    //             `--proxy-server=${ipObj.ip}:${ipObj.port}`
    //         ]
    //     };
    //     // const browser = await puppeteer.launch({headless: false});
    //     const browser = await puppeteer.launch(options);
    //     const page = await browser.newPage();
    //     await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36");
    //     await page.setViewport({width: 1366, height: 768});
    //     await page.goto('https://www.kuaishou.com/thirdPart/wechat');
    //     await page.addScriptTag({ 'path': 'assets/stealth.min.js' });
    // }
    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();
    await page.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36");
    await page.setViewport({width: 1366, height: 768});
    await page.goto('https://www.kuaishou.com/thirdPart/wechat');
    await page.addScriptTag({ 'path': 'assets/stealth.min.js' });
}

// const 

main();